import 'package:get/get.dart';
import 'package:xinxuan/controllers/common_page_controller.dart';
import 'package:xinxuan/controllers/my_controller/blind_box_order_controller/blind_box_order_page_controller.dart';
import 'package:xinxuan/http/http_util_service.dart';
import 'package:xinxuan/vo/blindbox/blind_box_order_detail_vo.dart';

class BlindBoxOrderDetailPageController extends GetxController {

  final BlindBoxOrderPageController blindBoxOrderPageController = Get.find();

  final CommonPageController commonPageController = Get.find();
  
  var appBarTitle = '订单详情'.obs;
  var orderId = 0.obs;

  var orderDetailData = BlindBoxOrderDetailData(id: 0, status: 0, voucherCode: '', transfer: []).obs;

  @override
  void onInit() {
    Map<String, dynamic> argumentsMap = Get.arguments;
    orderId.value = argumentsMap['id'];
    appBarTitle.value = argumentsMap['title'];
    update();
    super.onInit();
  }

  @override
  void onReady() {
    getBlindBoxOrderDetail();
    super.onReady();
  }

  /// 获取订单详情
  getBlindBoxOrderDetail({bool showLoading = true}) async {
    BlindBoxOrderDetailVo blindBoxOrderDetailVo = await HttpUtilService.getBlindBoxOrderDetail(orderId: orderId.value, loading: showLoading);
    orderDetailData.value = blindBoxOrderDetailVo.data!;
    appBarTitle.value = orderDetailData.value.statusStr ?? '';
    update();
  }

}